package com.wsit.service.impl;



import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wsit.mapper.ServerMapper;
import com.wsit.pojo.PageBean;
import com.wsit.pojo.Server;
import com.wsit.pojo.ServerPage;
import com.wsit.service.ServerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ServerServiceImpl implements ServerService {
    @Autowired
    private ServerMapper serverMapper;


    /**
     * 分页查询服务订单数据
     *
     * @param serverPage
     * @return
     */
    @Override
    public PageBean page(ServerPage serverPage) {
//        设置分页参数
        PageHelper.startPage(serverPage.getPage(), serverPage.getPageSize());
//        执行查询
        List<Server> list = serverMapper.list(serverPage);
//        解析封装分页结果
        Page<Server> p = (Page<Server>) list;
        return new PageBean(p.getTotal(),p.getResult());
    }

    /**
     * 添加服务订单
     *
     * @param server
     */
    @Override
    public void add(Server server) {
        serverMapper.add(server);
    }

    /**
     * 根据id查询服务订单
     *
     * @param id
     * @return
     */
    @Override
    public Server getById(Integer id) {
            return serverMapper.getById(id);

    }

    /**
     * 修改服务订单
     *
     * @param server
     */
    @Override
    public void update(Server server) {
        serverMapper.update(server);
    }

    /**
     * 根据id删除服务订单
     *
     * @param ids
     */
    @Override
    public void delete(List<Integer> ids) {
        serverMapper.delete(ids);
    }



}
